// Copyright (C) 2009, Jackie Ng
// http://code.google.com/p/mgfdo, jumpinjackie@gmail.com
// 
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
// 
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
// 
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
// 
//
// See license.txt for more/additional licensing information

#ifndef MGCONNECTIONINFO_H
#define MGCONNECTIONINFO_H

#include "MgProvider.h"
#include "FdoCommonConnPropDictionary.h"

class MgConnectionInfo : public FdoIConnectionInfo
{
	MG_IMPLEMENT_REFCOUNTING

private:
	FdoIConnection* mConnection;
	FdoPtr<FdoCommonConnPropDictionary> mConnProps;

public:
	MgConnectionInfo(FdoIConnection* conn) : m_refCount(1), mConnection(conn)
	{
		
	}

	~MgConnectionInfo() 
	{ 
		
	}

public:
    /// \brief
    /// Gets the name of the feature provider.
    /// 
    /// \return
    /// Returns the provider name
    /// 
	MG_API virtual FdoString* GetProviderName() { return PROVIDER_NAME; }

    /// \brief
    /// Gets the display name of the feature provider.
    /// 
    /// \return
    /// Returns the provider's display name
    /// 
	MG_API virtual FdoString* GetProviderDisplayName() { return PROVIDER_DISPLAY_NAME; }

    /// \brief
    /// Gets the description of the feature provider.
    /// 
    /// \return
    /// Returns the provider description
    /// 
	MG_API virtual FdoString* GetProviderDescription() { return PROVIDER_DESCRIPTION; }

    /// \brief
    /// Gets the version of the feature provider.
    /// 
    /// \return
    /// Returns provider version
    /// 
	MG_API virtual FdoString* GetProviderVersion() { return PROVIDER_VERSION; }

    /// \brief
    /// Gets the version of the Feature Data Objects specification to which this provider conforms.
    /// 
    /// \return
    /// Returns FDO version supported.
    /// 
	MG_API virtual FdoString* GetFeatureDataObjectsVersion() { return FDO_VERSION; }

    /// \brief
    /// Gets the FdoIConnectionPropertyDictionary interface that can be used to dynamically query and set the properties required to establish a connection.
    /// 
    /// \return
    /// Returns the property dictionary
    /// 
	MG_API virtual FdoIConnectionPropertyDictionary* GetConnectionProperties() 
	{ 
		if (NULL == mConnProps)
		{
			mConnProps = new FdoCommonConnPropDictionary(mConnection);
			FdoPtr<ConnectionProperty> prop = new ConnectionProperty(
					L"URL",
					L"URL",
					L"",
					true,
					false,
					false,
					false,
					false,
					false,
					false,
					0,
					NULL);
			//mapagent URL
			mConnProps->AddProperty(prop);
			//MG username
			prop = new ConnectionProperty(
					L"Username",
					L"Username",
					L"",
					true,
					false,
					false,
					false,
					false,
					false,
					false,
					0,
					NULL);
			mConnProps->AddProperty(prop);
			//MG Password
			prop = new ConnectionProperty(
					L"Password",
					L"Password",
					L"",
					false,
					true,
					false,
					false,
					false,
					false,
					false,
					0,
					NULL);
			mConnProps->AddProperty(prop);
			//MG Feature Source Id
			prop = new ConnectionProperty(
					L"FeatureSourceId",
					L"FeatureSourceId",
					L"",
					true,
					false,
					false,
					false,
					false,
					false,
					false,
					0,
					NULL);
			mConnProps->AddProperty(prop);
		}
		return FDO_SAFE_ADDREF(mConnProps.p);
	}

    /// \brief
    /// Returns the provider type. A provider can be a file-based, database-based or
    /// web-based provider. The valid values the function may return are defined in
    /// the enumeration FdoProviderDatastoreType. The enumeration includes the following
    /// values: FdoProviderDatastoreType_Unknown, FdoProviderDatastoreType_File,
    /// FdoProviderDatastoreType_DatabaseServer, FdoProviderDatastoreType_WebServer.
    /// 
    /// \return
    /// Returns the provider data store type.
    /// 
	MG_API virtual FdoProviderDatastoreType GetProviderDatastoreType() { return FdoProviderDatastoreType_WebServer; }

    /// \brief
    /// File-based providers depend on a various files. This function returns a list
    /// of fully qualified dependend file names. The return parameter will be NULL if
    /// the provider is not a file-based provider.
    /// 
    /// \return
    /// Returns the list of fully-qualified dependend file names if the provider is a
    /// file-based provider, NULL otherwise.
    /// 
	MG_API virtual FdoStringCollection* GetDependentFileNames() { return NULL; }
};

#endif